<?
session_start();
if (!isset($_SESSION["sess_Username"])) { 
?>
  <script>
	alert('กรุณาทำการ Login เข้าระบบก่อน');
	</script>
	<meta http-equiv='refresh' content='0;URL=admin_login.php'>
<? } 
include "connectdb.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ยินดีต้อนรับเข้าสู่ ระบบบริการสื่อมัลติมีเดียด้านการเกษตร</title>
<link rel="stylesheet" href="standard.css" type="text/css" />

<script language="JavaScript">
<!--
function doCheck1(which,id) {
	if(id=='1') {
	  if(which.checked==true) {
		document.frm_vdo_add.txtmanualpath.disabled = false;
		document.frm_vdo_add.cb_manualpath.value = "1";
	  } else {
		document.frm_vdo_add.txtmanualpath.disabled = true;
		document.frm_vdo_add.cb_manualpath.value = "0";
	  }
	}
}
// -->
</script>

<?php 
function check_vdotype(){
		echo "จำนวนที่เลือก => ".count($vdotype_array);
		if(count($vdotype_array)==0){
			?>
			<script>
				alert('กรุณาเลือกประเภทเนื้อหาอย่างน้อย 1 ประเภท');
				return false;
			</script>
			<?
		}elseif(count($vdotype_array)!=0){
			?>
			<script>
				return true;
			</script>
			<?
		}
}
?>

<script lanuage="javascript">
	function check_value() 
{
	if(document.frm_vdo_add.txtfile.value == "" && document.frm_vdo_add.cb_manualpath.value == "0" ){
			alert('กรุณาเลือกไฟล์')
			document.frm_vdo_add.txtfile.focus();
			return false;
	}else if(document.frm_vdo_add.txtname.value == ""){
			alert('กรุณากรอกชื่อรายการสื่อมัลติมีเดีย')
			document.frm_vdo_add.txtname.focus();
			return false;
	}else if(document.frm_vdo_add.txtauthor.value == ''){
			alert('กรุณากรอกชื่อหน่วยงาน/ชื่อผู้แต่ง');
			document.frm_vdo_add.txtauthor.focus();
			return false ;		
	}
	
//	else if(document.frm_vdo_add.txthour.value == '00' && document.frm_vdo_add.txtmin.value == '00' && document.frm_vdo_add.txtsec.value == '00'){
//			alert('กรุณากรอกความยาวสื่อมัลติมีเดีย');
//			document.frm_vdo_add.txtauthor.focus();
//			return false ;

	}else{	//ตรวจสอบว่ามีการกดปุ่ม checkbox หรือไม่
	
		var cb_count = 0;
		var frm_vdo_add = document.getElementById('frm_vdo_add');
		for(var i=0; i<frm_vdo_add['vdotype_array[]'].length; i++){
			if (frm_vdo_add['vdotype_array[]'][i].checked==true)
			{
				 cb_count = ++cb_count;
			}
		}
		if(cb_count<=0){
			alert('กรุณาเลือกประเภทเนื้อหาอย่างน้อย 1 ประเภท');
			return false;
		}else return true;

	}
}
</script>
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

</head>

<body onLoad="MM_preloadImages('img/m_main2.jpg','img/m_register2.jpg','img/m_multimedia2.jpg','img/m_manual2.jpg','img/m_evaluate2.jpg','img/m_admin2.jpg','img/m_static2.jpg','img/m_topten2.jpg')">
<table width="1024" height="659" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#666600">
  <tr>
    <td height="215" align="center" valign="top" bgcolor="#CCCCCC"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="170" background="img/headNew2.jpg" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table>
        <table width="824" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
          <tr>
            <td width="103" height="45" align="center"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','img/m_main2.jpg',1)"><img src="img/m_main.jpg" name="Image12" width="115" height="45" border="0" id="Image12" /></a></td>
            <td width="103" align="right"><a href="user_register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','img/m_register2.jpg',1)"><img src="img/m_register.jpg" name="Image13" width="115" height="45" border="0" id="Image13" /></a></td>
            <td width="103" align="right"><a href="vdo_list.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','img/m_multimedia2.jpg',1)"><img 
src="img/m_multimedia.jpg" name="Image14" width="117" height="45" border="0" id="Image14" /></a></td>
            <td width="103"><a href="vdo_top10.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','img/m_topten2.jpg',1)"><img 
src="img/m_topten.jpg" name="Image11" width="115" height="45" border="0" id="Image11" /></a></td>
            <td width="103"><a href="admin_report_search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','img/m_static2.jpg',1)"><img 
src="img/m_static.jpg" name="Image10" width="215" height="45" border="0" id="Image10" /></a></td>
            <td width="103"><a href="manual.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','img/m_manual2.jpg',1)"><img src="img/m_manual.jpg" name="Image9" width="117" height="45" border="0" id="Image9" /></a></td>
            <td width="103"><a href="evaluate_overview.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','img/m_evaluate2.jpg',1)"><img src="img/m_evaluate.jpg" name="Image8" width="115" height="45" border="0" id="Image8" /></a></td>
            <td width="103"><a href="admin_login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','img/m_admin2.jpg',1)"><img src="img/m_admin.jpg" name="Image15" width="115" height="45" border="0" id="Image15" /></a></td>
          </tr>
        </table></td>
  </tr>
  <tr>
    <td width="1024" height="66" align="center" valign="top" bgcolor="#FFFFFF"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_top.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
        <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="30" align="left" bgcolor="#CCFF00" class="style7"><span class="scapmain style7">&nbsp;<img src="img/img05.gif" align="absbottom" /> </span>เพิ่ิ่ิ่มรายการสื่อมัลติมีเดีย</td>
          </tr>
          <tr>
            <td align="center" bgcolor="#FFFFFF"><p>&nbsp;</p>
                    <table width="80%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999">
                      <form action="vdo_add2.php" method="post" name="frm_vdo_add" class="style17" id="frm_vdo_add"  onsubmit="return check_value();">
                        <tr>
                          <td height="30" colspan="4" align="center" bgcolor="#FFCC33" class="style24">รายละเอียด</td>
                        </tr>
                        
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;File</td>
                          <td height="50" colspan="3" align="left" valign="middle" bgcolor="#FFEC8D"><input name="txtfile" type="file" id="txtfile" size="50" />                         <span class="style29">*</span><span class="style20">
                               
                              <br />
                          </span><span class="style29">(สนับสนุนไฟล์ประเภท wmv , wma และชื่อไฟล์เป็นภาษาอังกฤษ)</span></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;Manual Path</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D">
                          <input name="cb_manualpath" type="checkbox" id="cb_manualpath" value="0" onclick="doCheck1(this,'1');" />
                          <input name="txtmanualpath" type="text" id="txtmanualpath" size="40"  value="" disabled />
                          </td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ชื่อชุด</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><input name="txtsrname" type="text" id="txtsrname" size="40" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ชื่อเรื่อง</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><input name="txtname" type="text" id="txtname" size="40" />                            <span class="style29">*</span><span class="style20">
                            
                           </span></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;คำบรรยายเพิ่มเติม</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><textarea name="txtdesc" id="txtdesc" cols="47" rows="5"></textarea></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;หน่วยงาน / ชื่อผู้แต่ง</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><input name="txtauthor" type="text" id="txtauthor" size="40" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ปีที่จัดทำ</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><input name="txtyear" type="text" id="txtyear" size="4" maxlength="4" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;หน้าปก</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D"><input name="txtcover" type="text" id="txtcover" size="40" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ความยาว</td>
                          <td height="30" colspan="3" align="left" bgcolor="#FFEC8D">
                          <select name="txthour" id="txthour">
                            <option value="00">00</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            </select>
                            <span class="style24">ชม :</span> 
                            <select name="txtmin" id="txtmin">
                            <option value="00">00</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                            <option value="25">25</option>
                            <option value="26">26</option>
                            <option value="27">27</option>
                            <option value="28">28</option>
                            <option value="29">29</option>
                            <option value="30">30</option>
                            <option value="31">31</option>
                            <option value="32">32</option>
                            <option value="33">33</option>
                            <option value="34">34</option>
                            <option value="35">35</option>
                            <option value="36">36</option>
                            <option value="37">37</option>
                            <option value="38">38</option>
                            <option value="39">39</option>
                            <option value="40">40</option>
                            <option value="41">41</option>
                            <option value="42">42</option>
                            <option value="43">43</option>
                            <option value="44">44</option>
                            <option value="45">45</option>
                            <option value="46">46</option>
                            <option value="47">47</option>
                            <option value="48">48</option>
                            <option value="49">49</option>
                            <option value="50">50</option>
                            <option value="51">51</option>
                            <option value="52">52</option>
                            <option value="53">53</option>
                            <option value="54">54</option>
                            <option value="55">55</option>
                            <option value="56">56</option>
                            <option value="57">57</option>
                            <option value="58">58</option>
                            <option value="59">59</option>
                            </select>
                            <span class="style24">นาที 
                           : 
                            <select name="txtsec" id="txtsec">
                            <option value="00">00</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                            <option value="25">25</option>
                            <option value="26">26</option>
                            <option value="27">27</option>
                            <option value="28">28</option>
                            <option value="29">29</option>
                            <option value="30">30</option>
                            <option value="31">31</option>
                            <option value="32">32</option>
                            <option value="33">33</option>
                            <option value="34">34</option>
                            <option value="35">35</option>
                            <option value="36">36</option>
                            <option value="37">37</option>
                            <option value="38">38</option>
                            <option value="39">39</option>
                            <option value="40">40</option>
                            <option value="41">41</option>
                            <option value="42">42</option>
                            <option value="43">43</option>
                            <option value="44">44</option>
                            <option value="45">45</option>
                            <option value="46">46</option>
                            <option value="47">47</option>
                            <option value="48">48</option>
                            <option value="49">49</option>
                            <option value="50">50</option>
                            <option value="51">51</option>
                            <option value="52">52</option>
                            <option value="53">53</option>
                            <option value="54">54</option>
                            <option value="55">55</option>
                            <option value="56">56</option>
                            <option value="57">57</option>
                            <option value="58">58</option>
                            <option value="59">59</option>
                            </select>
                            วินาที                            </span></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;คำสำคัญ</td>
                          <td height="30" colspan="2" align="left" bgcolor="#FFEC8D"><textarea name="txtkeyword" id="txtkeyword" cols="30" rows="3"></textarea></td>
                          <td width="402" height="30" align="center" bgcolor="#FFEC8D" class="style27">&nbsp;<span class="style29">*</span> ตัวอย่าง : keyword1,keyword2</td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ประเภทเนื้อหา</td>
                          <td width="196" height="30" align="left" bgcolor="#FFEC8D" class="style24">
                            <?php 
        $SQL_SELECT_VDOTYPE = "SELECT * FROM ag_vdotype ORDER BY vdo_typeid desc";
        $result = mysql_query($SQL_SELECT_VDOTYPE);
        while ( $rs = mysql_fetch_array( $result ) ) //นำค่าี่ที่ผ่านการคิวรี่จากตัวแปร $result มาทำการวนลูปเพื่อเอาค่าในแต่ละฟิลด์ออกมาโชว์แสดงผล
	{ 
			$vdo_typeid = $rs[vdo_typeid];									
			$vdo_type = $rs[vdo_type];													
			
			$bgcolorj = ($j++%2)?'#f7fdea':'#ffffff';
				echo"<dd><input type='checkbox' name='vdotype_array[]' value=$vdo_typeid onclick='check(this)'>
					   &nbsp;<font color='#372412' size='2'>$vdo_type</font><br>
					 ";}
        
        ?>                          </td>
                          <td height="30" colspan="2" align="center" bgcolor="#FFEC8D"><span class="style29">*</span> <span class="style27">กรุณาเลือกอย่างน้อย 1 ประเภท</span></td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style24">&nbsp;ประเภทของไฟล์สื่อมัลติมีเดีย&nbsp;</td>
                          <td height="30" align="left" bgcolor="#FFEC8D"><span class="style8">
                            <?php 
        $SQL_SELECT_MEDIATYPE = "SELECT * FROM ag_mediatype ORDER BY media_typeid";
        $result = mysql_query($SQL_SELECT_MEDIATYPE);
        while ( $rs = mysql_fetch_array( $result ) ) //นำค่าี่ที่ผ่านการคิวรี่จากตัวแปร $result มาทำการวนลูปเพื่อเอาค่าในแต่ละฟิลด์ออกมาโชว์แสดงผล
	{ 
			$media_typeid = $rs[media_typeid];									
			$media_type = $rs[media_type];													
			
			$bgcolorj = ($j++%2)?'#f7fdea':'#ffffff';
				echo"<dd>"
				?>
                        <input type='radio' name='mediatype_array[]' value="<?=$media_typeid ?>" <? if($media_typeid==1)echo'checked'; ?> />
                            &nbsp;<font color='#372412' size='2'>
                              <?=$media_type?>
                              </font><br />
                            <?  }
        
        ?>
                          </span></td>
                          <td height="30" colspan="2" align="left" bgcolor="#FFEC8D">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="30" align="left" nowrap="nowrap" bgcolor="#FFEC8D" class="style28">&nbsp;แนะนำ</td>
                          <td height="30" colspan="3" align="left" nowrap="nowrap" bgcolor="#FFEC8D">
                         <dd> <input name="cb_recommend" type="checkbox" id="cb_recommend" value="1" />
                           <span class="style28">ติ๊กเพื่อตั้งเป็นสื่อมัลติมีเดียแนะนำ</span></td>
                        </tr>
                        <tr>
                          <td height="30" colspan="4" align="center" nowrap="nowrap" bgcolor="#FFCC33">
                          <input type="submit" name="button" id="button" value="เพิ่ม" />
                              <a name="top" id="space"></a>
                              <input type="reset" name="button2" id="button2" value="ล้าง" />
                          &nbsp;</td>
                        </tr>
                      </form>
                  </table>
                  <p>&nbsp;</p>
              <p>&nbsp;</p></td>
          </tr>
          <tr>
            <td height="25" bgcolor="#CCFF00">&nbsp;</td>
          </tr>
        </table></td>
        <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_foot.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="1024" align="center" valign="bottom"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="25">&nbsp;</td>
      </tr>
    </table>
        <table width="1024" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="50"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
                  <td background="img/tb/tb_top.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
                  <td height="25" align="center" valign="middle" bgcolor="#CCFF00"><table width="96%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="25" align="center"><strong>ศูนย์ความรู้ด้านการเกษตร สำนักหอสมุด มหาวิทยาลัยเกษตรศาสตร์</strong></td>
                      </tr>
                  </table></td>
                  <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
                  <td background="img/tb/tb_foot.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
                </tr>
            </table></td>
          </tr>
      </table></td>
  </tr>
</table>
<p>&nbsp;</p>

</body>
</html>
<script>
getdetail();
</script>